﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using Eloquera.Client;
using Model;

namespace _430GroupProject
{
    //Every user in the system is a user with certain permissions and alerts.
    [DataContractAttribute]
    public class User : SuperClass
    {
        [DataMember, ID]
        public String UserID;

        [DataMember]
        public String NetID { get; set; }
        [DataMember]
        public String UniversityID { get; set; }
        [DataMember]
        public String Email { get; set; }
        [DataMember]
        public String FullName { get; set; }
        
        //List of workgroups that is user works in.
        [DataMember]
        public List<String> WorksIn { get; set; }

        //List of workgroups that this user is a supervisor for.
        [DataMember]
        public List<String> Manages { get; set; }
        [DataMember]
        public String Password { get; set; }
        [DataMember]
        public List<Permission> Permissions { get; set; }
        [DataMember]
        public List<Alert> Alerts { get; set; }


        public User(String NetID, String UniversityID, String Email, String fullName) {
            this.NetID = NetID;
            this.UniversityID = UniversityID;
            this.Email = Email;
            this.FullName = fullName;

            this.Alerts = new List<Alert>();
            this.WorksIn = new List<String>();
            this.Manages = new List<String>();
        }

        public override bool Equals(object obj)
        {
            if(obj == null) return false;
            if (obj.GetType() != this.GetType())
                return false;
            User other = (User)obj;
            if (!other.NetID.Equals(this.UserID)) return false;
            if (!other.Password.Equals(this.Password)) return false;
            if (!other.FullName.Equals(this.FullName)) return false;
            return true;
        }
    }

    //Holds a list of User object.
    [DataContractAttribute]
    public class Users : SuperClass
    {
        [DataMember]
        public List<User> Accounts { get; set; }
    }
}
